/* ----------------------------------------------------------------------------
* File: api_message_sender_impl.h
*
* Desc: Skype message sender implementation
*
* Created: 30/07/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _API_MESSAGE_SENDER_IMPL_H_
#define _API_MESSAGE_SENDER_IMPL_H_

#include "utils.h"
#include "api_message_sender.h"
#include "api_proxy.h"
#include "sending_request.h"

namespace SkypeProtection
{
	class APIMessageSenderImpl
		: public APIMessageSender
		, public APIProxy
	{
	public:
		APIMessageSenderImpl();
		~APIMessageSenderImpl();

		// SkypeProxy implementation
		virtual Common::Error RunLogic(SKYPE4COMLib::ISkype* skype);

		// SkypeMessageSender implementation
		Common::Error AsyncSendMessage(const std::string& ChatName, const std::string& Message);

	private:
		Common::Error StartProxyProcess(SKYPE4COMLib::ISkype* skype);
		Common::Error StopProxyProcess(SKYPE4COMLib::ISkype* skype);
		void ProcessRequests(SKYPE4COMLib::ISkype* Skype);
		SKYPE4COMLib::IChatPtr FindChatByName(SKYPE4COMLib::ISkype* Skype, const std::string& ChatName);
		Common::Error SendData(SKYPE4COMLib::ISkype* Skype, const SendingRequest& request);

		std::auto_ptr<Common::Utils::ConcurrentQueue<SendingRequest>> m_RequestQueue;
	};
}

#endif // _API_MESSAGE_SENDER_IMPL_H_